#include<iostream>
#include<map>
using namespace std;
const int N=2e4+10;
int n;
map<int,int>vis;
int maxx=-1,minn=1e7;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int num;
		cin>>num;
		maxx=max(maxx,num);
		minn=min(minn,num);
		vis[num]++;
	}
	cout<<minn<<' '<<vis[minn]<<endl;
	cout<<maxx<<' '<<vis[maxx]<<endl;
	return 0;
}
